//
//  PopoverPresentedView.swift
//  Created by jyh on 2017/11/30.
//  Copyright © 2017年 jyh. All rights reserved.
//

import UIKit

class PopoverPresentedView: UIPresentationController {
    
    // 保存菜单尺寸
    var presentFrame = CGRect.zero
    
    override func containerViewWillLayoutSubviews() {
        
        presentedView?.frame = presentFrame
        containerView?.insertSubview(coveButton, at: 0)
        coveButton.addTarget(self, action: #selector(self.coveBtnClick), for: .touchUpInside)
        
    }
    
    // 先添加一个button 在 menu菜单后面
    private lazy var coveButton: UIButton = {
        let btn = UIButton()
        btn.frame = UIScreen.main.bounds
        return btn
    }()
    
    func coveBtnClick() {
        presentedViewController.dismiss(animated: true, completion: nil)
    }
}
